<template>
  <div class="menu-wrapper">
    <el-card class="box-card">
      <div ref="memberForm">
        <div style="width: 100%;display: flex; justify-content: space-between; align-items: flex-end;border-bottom: 1px #eee solid;margin-bottom: 20px">
          <span style="font-size: 18px;color:#409EFF;margin: 10px 0;">账号信息</span>
<!--          <div style="margin-bottom: 10px">-->
<!--           <el-button  type="primary" v-permission="['member.edit']" @click="editClick">修改</el-button>-->
<!--          </div>-->
        </div>
         <el-row :gutter="24" class="deleted_OrderContent">
          <el-col :span="8">
            <span class="deleted_Row_Headings">账号：</span>
            <span class="deleted_OrderTitle">{{ form.mobile }}</span>
          </el-col>
          <el-col :span="8">
            <span class="deleted_Row_Headings">密码：</span>
            <span class="deleted_OrderTitle">{{ form.code }}</span>
          </el-col>
         <el-col :span="8">
            <span class="deleted_Row_Headings">姓名：</span>
            <span class="deleted_OrderTitle">{{ form.name }}</span>
          </el-col>
        </el-row>
        <el-row :gutter="24" class="deleted_OrderContent">
          <el-col :span="8">
            <span class="deleted_Row_Headings">付款方式：</span>
            <span class="deleted_OrderTitle">{{form.paymentPluginId | watchPayment}}</span>
          </el-col>
               <el-col :span="8">
            <span class="deleted_Row_Headings">等级：</span>
            <span class="deleted_OrderTitle">{{ form.vipName }}</span>
          </el-col>
          <el-col :span="8">
            <span class="deleted_Row_Headings">所在地：</span>
            <span class="deleted_OrderTitle_app">{{ form.areaName }}</span>
          </el-col>
        </el-row>
        <!--<el-row :gutter="24" class="deleted_OrderContent" v-if="scopeType == 3">-->
          <!--<el-col :span="8">-->
          <!--<div style="margin-top: 20px;display: flex;">-->
                <!--<span class="deleted_Row_Headings">订水码：</span>-->
                <!--<img :src="bindingImage" alt="" style="width:100px;height:100px;margin-left:10px">-->
             <!--</div>-->
          <!--</el-col>-->
          <!--<el-col :span="8">-->
               <!--<div style="margin-top: 20px;display: flex;" v-if='form.userId'>-->
                <!--<span class="deleted_Row_Headings">邀请码：</span>-->
                <!--<img :src="Invitationcode" alt="" style="width:100px;height:100px;margin-left:10px">-->
             <!--</div>-->
          <!--</el-col>-->
        <!--</el-row>-->
        <el-tabs v-model="activeName" style="margin-top: 20px;" @tab-click="tabsClick">
          <el-tab-pane label="基础信息" name="otherInfo">
                  <el-row :gutter="24" class="deleted_OrderContent">
              <el-col :span="8">
                <span class="deleted_Row_Headings">所属门店：</span>
                <span class="deleted_OrderTitle">{{ form.shopName }}</span>
              </el-col>
              <el-col :span="8">
                 <span class="deleted_Row_Headings">分类：</span>
                 <span class="deleted_OrderTitle" style="color: rgb(64, 158, 255)">{{ form.memberCategoryName }}</span>
              </el-col>
            </el-row>
            <el-row :gutter="24" class="deleted_OrderContent">
              <el-col :span="8">
                <span class="deleted_Row_Headings">经理：</span>
                <span class="deleted_OrderTitle">{{ managerName }}</span>
              </el-col>
              <el-col :span="8">
              <span class="deleted_Row_Headings">推荐人：</span>
              <span class="deleted_OrderTitle">{{ promoterName }}</span>
            </el-col>
            </el-row>
            <el-row :gutter="24" class="deleted_OrderContent">
              <el-col :span="24">
                <span class="deleted_Row_Headings">备用电话：</span>
                <span class="deleted_OrderTitle">{{ form.phone }}</span>
              </el-col>
            </el-row>

            <el-row :gutter="24" class="deleted_OrderContent">
              <el-col :span="24">
                <span class="deleted_Row_Headings">备注：</span>
                <span class="deleted_OrderTitle">{{ form.memo }}</span>
              </el-col>
            </el-row>
            <el-row :gutter="24" class="deleted_OrderContent">
              <el-col :span="24">
                <span class="deleted_Row_Headings">纳税识别号：</span>
                <span class="deleted_OrderTitle">{{ form.taxNum }}</span>
              </el-col>
            </el-row>

            <div style="margin-top: 20px" class="details_PayHeader" v-if="realNameInfo!=null">
              <div class="deleted_Line"></div>
              <span class="details_HeaderTitle">实名信息</span>
            </div>
            <div  v-if="realNameInfo!=null">
              <el-row :gutter="24" class="deleted_OrderContent">
                <el-col :span="8">
                  <span class="deleted_Row_Headings">真实姓名：</span>
                  <span class="deleted_OrderTitle" style="color: rgb(64, 158, 255)">{{realNameInfo.cardName}}</span>
                </el-col>
              </el-row>
              <el-row :gutter="24" class="deleted_OrderContent">
                <el-col :span="10">
                  <span class="deleted_Row_Headings">身份证号：</span>
                  <span class="deleted_OrderTitle" style="color: rgb(64, 158, 255)">{{realNameInfo.idCardNo}}
                     <span v-if="idCardNoState==81 ||idCardNoState==82 ||idCardNoState==83 " class="deleted_OrderTitle" style="color:red">(港澳台)</span>
              </span>
                </el-col>
              </el-row>
              <el-row :gutter="24" class="deleted_OrderContent">
                <el-col :span="8">
                  <span class="deleted_Row_Headings">实名状态：</span>
                  <span v-if="realNameStatus==0" class="deleted_OrderTitle" style="color: rgb(64, 158, 255)">未实名</span>
                  <span v-if="realNameStatus==1" class="deleted_OrderTitle" style="color: rgb(64, 158, 255)">已申请</span>
                  <span v-if="realNameStatus==2" class="deleted_OrderTitle" style="color: rgb(64, 158, 255)">已实名</span>
                  <span v-if="realNameStatus==3" class="deleted_OrderTitle" style="color: rgb(64, 158, 255)">已驳回</span>
                </el-col>
              </el-row>
            </div>
          </el-tab-pane>
          <el-tab-pane label="账户信息" name="wallet">
            <el-row :gutter="24" class="deleted_OrderContent">
              <el-col :span="8" >
                <span class="deleted_Row_Headings">红包：</span>
                <span class="deleted_OrderTitle deleted_OrderTitle_changedisplay"  style="color: #ff0000">{{ form.point /100}}</span>
                <el-button type="text" @click="pointClick(0)" style="margin-left: 20px;"><span style="font-size: 15px; font-weight: 500">查看详情</span></el-button>
              </el-col>
              <el-col :span="8" >
                <span class="deleted_Row_Headings">会员卡：</span>
                <span class="deleted_OrderTitle deleted_OrderTitle_changedisplay"  style="color: #ff0000">{{ cardBalance }}</span>
                <el-button type="text" @click="pointClick(3)" style="margin-left: 20px;"><span style="font-size: 15px; font-weight: 500">查看详情</span>
                </el-button>
                <el-button type="text" @click="Rechargeclick('memberShipCard')" style="margin-left: 20px;"><span style="font-size: 15px; font-weight: 500">充值</span>
                </el-button>
              </el-col>
            </el-row>
            <el-row :gutter="24" class="deleted_OrderContent">
              <el-col :span="8">
                <span class="deleted_Row_Headings">购物券：</span>
                <span class="deleted_OrderTitle deleted_OrderTitle_changedisplay" style="color: #409EFF">{{ form.matchPoint/ 100 }}</span>
                <el-button type="text" @click="pointClick(1)" style="margin-left: 20px;"><span style="font-size: 15px; font-weight: 500">查看详情</span></el-button>
              </el-col>
                <el-col :span="8">
                <span class="deleted_Row_Headings">福利卡：</span>
                <span class="deleted_OrderTitle deleted_OrderTitle_changedisplay"  style="color: #ff0000">{{benefits}}</span>
                <el-button type="text" @click="pointClick(5)" style="margin-left: 20px;"><span style="font-size: 15px; font-weight: 500">查看详情</span></el-button>
              </el-col>
            </el-row>
            <el-row :gutter="24" class="deleted_OrderContent">
               <el-col :span="8">
                  <span class="deleted_Row_Headings">钱包：</span>
                  <span class="deleted_OrderTitle deleted_OrderTitle_changedisplay" style="color: red">{{ balance }}</span>
                  <el-button type="text" @click="pointClick(2)" style="margin-left: 20px;"><span style="font-size: 15px; font-weight: 500">查看详情</span></el-button>
              </el-col>
               <el-col :span="8">
                <span class="deleted_Row_Headings">兑换券：</span>
                <span class="deleted_OrderTitle deleted_OrderTitle_changedisplay"  style="color: #ff0000">{{ groupBuy }}</span>
                <el-button type="text" @click="pointClick(7)" style="margin-left: 20px;"><span style="font-size: 15px; font-weight: 500">查看详情</span></el-button>
                <el-button type="text" @click="Rechargeclick('groupPurchaseCoupon')" style="margin-left: 20px;"><span style="font-size: 15px; font-weight: 500">充值</span></el-button>
                </el-col>
            </el-row>
            <el-row :gutter="24" class="deleted_OrderContent">
<!--              <el-col :span="8">-->
<!--                <span class="deleted_Row_Headings">电子水票：</span>-->
<!--                <span class="deleted_OrderTitle deleted_OrderTitle_changedisplay"  style="color: #ff0000">{{ virtualStock }}</span>-->
<!--                <el-button type="text" @click="pointClick(6)" style="margin-left: 20px;"><span style="font-size: 15px; font-weight: 500">查看详情</span></el-button>-->
<!--              </el-col>-->
              <el-col :span="8">
                 <span class="deleted_Row_Headings">优惠卷：</span>
                 <span class="deleted_OrderTitle deleted_OrderTitle_changedisplay"  style="color: #ff0000">{{ couponCodeNum }}</span>
                 <el-button type="text" @click="pointClick(4)" style="margin-left: 20px;"><span style="font-size: 15px; font-weight: 500">查看详情</span></el-button>
              </el-col>
              <el-col :span="8">
                <span class="deleted_Row_Headings">分红权：</span>
                <span class="deleted_OrderTitle deleted_OrderTitle_changedisplay"  style="color: #ff0000">{{ stockRight}}</span>
<!--                <el-button type="text" @click="pointClick(7)" style="margin-left: 20px;"><span style="font-size: 15px; font-weight: 500">查看详情</span></el-button>-->
                <el-button type="text" @click="dividendBond('dividendBond')" style="margin-left: 20px;"><span style="font-size: 15px; font-weight: 500">加权</span></el-button>
              </el-col>
            </el-row>
          </el-tab-pane>
          <el-tab-pane label="收货地址" name="receiver">
            <div style="display: flex; justify-content: flex-end; margin-bottom: 10px; width: 100%;" v-permission="['member.edit']">
              <el-button type="primary" @click="showAddReceiver">新增地址</el-button>
            </div>
            <el-table v-loadMore="[payLoads,'receiver-list']" :data="receiverList" border stripe style="width: 100%">
              <el-table-column label="序号" type="index" width="50" align="center" />
              <el-table-column label="收货人" align="left" prop="consignee" width="100" />
              <el-table-column label="联系电话" align="left" prop="phone" width="110" />
              <el-table-column label="详细地址" align="left" prop="address" />
              <el-table-column label="操作" align="center" fixed="right" width="80" v-permission="['member.edit']">
                <template slot-scope="scope">
                  <a @click="showEditReceiver(scope.row)">
                    <i style="color: #409EFF" class="el-icon-edit" />
                  </a>
                  <a style="margin-left: 10px" @click="delAddress(scope.row)">
                    <i style="color: #F56C6C" class="el-icon-delete" />
                  </a>
                </template>
              </el-table-column>
            </el-table>
          </el-tab-pane>
          <el-tab-pane v-if="scopeType == 3" label="电子水票" name="water">
              <div style="display: flex;justify-content: space-between;align-items: center">
                <div style="display: flex; margin-bottom: 15px;">
                  <p style="margin-left: 10px;">电子水票: {{ virtualStock }} 张  </p>
                </div>
              </div>

            <el-table :data="waterList" border stripe style="width: 100%">
              <el-table-column label="序号" type="index" width="50" align="center" />
              <el-table-column label="缩略图" align="left" prop="thumbnail" width="80">
                <template slot-scope="scope">
                  <img :src="scope.row.thumbnail" style="width: 50px; vertical-align:middle; overflow: hidden;">
                </template>
              </el-table-column>
              <el-table-column label="水票名称" align="left" prop="name" />
              <el-table-column label="可用张数" align="right" prop="stock" width="100" />
              <el-table-column label="价格" align="right" prop="price" width="100" />
              <el-table-column label="说明" align="center">
                <template>
                  <div class="coupon-couponList-port2-text3">有限期永久有效</div>
                </template>
              </el-table-column>
            </el-table>

          </el-tab-pane>
          <el-tab-pane v-if="scopeType == 3" label="空桶记录"   name="emptyBarrel">
            <div>
              <div style="display: flex;justify-content: space-between;align-items: center">
                <div style="display: flex; margin-bottom: 15px;">
                  <p style="margin-left: 10px;">押桶数: {{ stock }} (<em style="color: red">{{ price }}元</em>) </p>
                </div>
                <div style="display: flex"  v-permission="['member.edit']" >
                  <el-button type="primary" @click="memberAddClick">押桶登记</el-button>
                  <el-button type="primary" @click="memberReturnClick">退桶登记</el-button>
                </div>
              </div>
              <el-table :data="plegdeList" border stripe style="width: 100%">
                <el-table-column label="序号" type="index" width="50" align="center" />
                <el-table-column label="缩略图" align="left" prop="thumbnail" width="80">
                  <template slot-scope="scope">
                    <img :src="scope.row.thumbnail" style="width: 50px; vertical-align:middle; overflow: hidden;">
                  </template>
                </el-table-column>
                <el-table-column label="时间" align="left" width="180">
                  <template slot-scope="scope">
                    {{ scope.row.createDate | datetimeFormatter }}
                  </template>
                </el-table-column>
                <el-table-column label="空桶名称" align="left" prop="name" />
                <el-table-column label="数量" align="right" prop="stock" width="100" />
                <el-table-column label="押金" align="right" prop="price" width="100" />
                <el-table-column label="说明" align="center">
                  <template slot-scope="scope">
                    <div v-if="scope.row.totalInStock!=scope.row.totalOutStock">未退桶</div>
                    <div v-else>已退桶</div>
                  </template>
                </el-table-column>
              </el-table>
            </div>

            <div style="margin-top: 10px">
              <div style="display: flex; justify-content: space-between; margin-bottom: 15px;">
                <div style="display: flex">
                  <p style="margin-right: 10px">存桶数: {{ emptyBarrelMany }}</p>
                  <p>欠桶数: {{ emptyBarrelLess }}</p>
                </div>

                <div  v-permission="['member.edit']" >
                  <el-button type="primary" @click="outDepositShow">欠桶登记</el-button>
                  <el-button type="primary" @click="returnDepositShow">存桶登记</el-button>
                </div>
              </div>
              <el-table :data="emptyBarrelList" border stripe style="width: 100%">
                <el-table-column label="序号" type="index" width="50" align="center" />
                <el-table-column label="缩略图" align="left" prop="thumbnail" width="80">
                  <template slot-scope="scope">
                    <img :src="scope.row.thumbnail" style="width: 50px; vertical-align:middle; overflow: hidden;">
                  </template>
                </el-table-column>
                <el-table-column label="时间" align="left" width="180">
                  <template slot-scope="scope">
                    {{ scope.row.createDate | datetimeFormatter }}
                  </template>
                </el-table-column>
                <el-table-column label="空桶名称" align="left" prop="name" />
                <el-table-column label="单位" align="left" prop="unit" width="100" />
                <el-table-column label="数量" align="right" prop="quantity" width="100">
                  <template slot-scope="scope">
                    <span :style="{'color': scope.row.quantity >= 0? '': 'red' }">{{ scope.row.quantity }}</span>
                  </template>
                </el-table-column>
                <el-table-column label="说明" align="center" prop="memo" />
              </el-table>
            </div>



          </el-tab-pane>
          <el-tab-pane label="批发商品" name="market">
            <div style=" display: flex; justify-content: flex-start; margin-bottom: 10px; width: 100%;">
                <div style="display: flex;flex-direction: column;align-items: flex-end;margin-right: 20px">
                  <el-select value-key="id" v-model="productTitle" filterable clearable :filter-method="remoteMethod" @change="marketChoose" placeholder="请选择商品">
                    <el-option
                      v-for="(item,index) in productForm"
                      :key="index"
                      :label="item.name"
                      :value="index"
                      style="width: 305px">
                    </el-option>
                    <div style="display: flex;width: 100%;position: absolute;bottom: 0">
                      <div style="width: 50%;background-color: rgb(248,248,248);"></div>
                      <el-button type="primary" class="elOption" @click="toAddProduct">搜索商品</el-button>
                    </div>
                  </el-select>
                </div>
                <el-button slot="reference" @click="creatClick">新增商品</el-button>
            </div>
            <el-table v-loadMore="[payLoads,'market-list']" :data="marketForm" border stripe style="width: 100%">
              <el-table-column label="序号" type="index" width="50" align="center" />
              <el-table-column label="货号" align="left" prop="sn" width="100" />
              <el-table-column label="缩略图" align="left" prop="thumbnail" width="100">
                <template slot-scope="scope">
                  <el-image style="width: 78px;height: 78px" :src="scope.row.thumbnail"></el-image>
                </template>
              </el-table-column>
              <el-table-column label="商品名称" align="left" prop="name" />
              <el-table-column label="销售价" align="left" prop="price" width="160">
                <template slot-scope="scope">
                  <el-input type="number" @focus="focusMarket($event,scope.row)"  @change="changeMarket($event,scope.row)" v-model="scope.row.price" placeholder="请输入销售价"></el-input>
                </template>
              </el-table-column>
              <el-table-column label="操作" align="center" fixed="right" width="80">
                <template slot-scope="scope">
                  <a style="" @click="delMarketClick(scope.row)">
                    <i style="color: #F56C6C" class="el-icon-delete" />
                  </a>
                </template>
              </el-table-column>
            </el-table>
          </el-tab-pane>
          <el-tab-pane  label="消费订单" name="shopping">
            <div class="details_card"  :style="{height:tabsHeight=400 +'px'}">
              <memberList :orderForm="orderForm" @detailsClick="detailsClick"></memberList>
            </div>
          </el-tab-pane>
          <el-tab-pane  label="付款记录" name="payment">
            <el-table :data="paymentList" border stripe style="width: 100%">
              <el-table-column label="序号" type="index" width="50" align="center" />
              <el-table-column label="创建时间" align="left" prop="dateFormatter" width="180">
                <template slot-scope="scope">
                  {{ scope.row.createDate | datetimeFormatter }}
                </template>
              </el-table-column>
              <el-table-column label="摘要" align="left" prop="memo" />
              <el-table-column label="购买人" align="left" prop="name" width="110" />
              <el-table-column label="联系方式" align="center" prop="mobile" width="110" />
              <el-table-column label="付款状态" align="left" width="80">
                <template slot-scope="scope">
                  {{ scope.row.status | watchStatus }}
                </template>
              </el-table-column>
              <el-table-column label="金额" align="right" prop="amount" width="80" />
              <el-table-column label="收款时间" align="left" width="160">
                <template slot-scope="scope">
                  {{ scope.row.paymentDate | datetimeFormatter }}
                </template>
              </el-table-column>
              <el-table-column label="查看详情" align="center" width="80">
                <template slot-scope="scope">
                  <el-button type="primary" size="mini" @click="toPayment(scope.row)">
                    详情
                  </el-button>
                </template>
              </el-table-column>
            </el-table>
          </el-tab-pane>
          <el-tab-pane  label="退款记录" name="refunds">
            <el-table :data="refundList" border stripe style="width: 100%">
              <el-table-column label="序号" type="index" width="50" align="center" />
              <el-table-column label="创建日期" align="left" prop="dateFormatter" width="180">
                <template slot-scope="scope">
                  {{ scope.row.createDate | datetimeFormatter }}
                </template>
              </el-table-column>
              <el-table-column label="摘要" align="left" prop="memo" />
              <el-table-column label="购买人" align="left" prop="name" width="110" />
              <el-table-column label="联系方式" align="center" prop="mobile" width="110" />
              <el-table-column label="付款状态" align="left" width="80">
                <template slot-scope="scope">
                  {{ scope.row.status | watchStatus }}
                </template>
              </el-table-column>
              <el-table-column label="金额" align="right" prop="amount" width="80" />
              <el-table-column label="退款时间" align="left" width="160">
                <template slot-scope="scope">
                  {{ scope.row.expire | datetimeFormatter }}
                </template>
              </el-table-column>
              <el-table-column label="查看详情" align="center" width="80">
                <template slot-scope="scope">
                  <el-button type="primary" size="mini" @click="toRefund(scope.row)">
                    详情
                  </el-button>
                </template>
              </el-table-column>
            </el-table>
          </el-tab-pane>
          <el-pagination
            v-if="paginationShow"
            style="padding-top: 15px;"
            :current-page="pageNum"
            :page-sizes="[5, 10, 15, 20]"
            :page-size="pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="total"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
          />
        </el-tabs>
      </div>
    </el-card>
    <el-dialog :title="bomTile" width="650px" :visible.sync="returnVisible">
      <div class="el-dialog-div">
      <el-form ref="emptyBarrelRef" :rules="emptyBarrelRules" label-width="80px">
        <el-form-item label="商品名称" >
      <el-select value-key='id' v-model="productTongName" placeholder="请选择" @change="productTongNamechang">
         <el-option
           v-for="item in TongProduct"
          :key="item.id"
          :label="item.name"
          :value="item">
         </el-option>
           </el-select>
        </el-form-item>
        <el-form-item label="押金名称" >
      <el-select value-key='id' v-model="productName" placeholder="请选择" @change="productIdchang">
         <el-option
           v-for="item in products"
          :key="item.id"
          :label="item.name"
          :value="item">
         </el-option>
           </el-select>
        </el-form-item>
          <el-form-item label="押桶数量">
          <el-input  v-model="obbitem.quality" style="width: 205px" type="Number" clearable />
        </el-form-item>
      </el-form>
        <div style="display: flex;justify-content: space-between;align-items: center;margin-top: 15px">
          <div>
          <span style="font-size: 14px;color: #606266;font-weight:700;margin-right:20px">收款方式</span>
          <el-select  clearable placeholder="请选择收款方式"
                      filterable style="width: 205px;margin-bottom: 10px" v-model="paymentPluginId">
            <el-option v-for="item in payments" :key="item.id" :label="item.name" :value="item.paymentPluginId" />
          </el-select>
          </div>
          <el-button type="primary" size="mini"  @click="selectBom">{{bomTile}}</el-button>
        </div>
      </div>
    </el-dialog>
    <el-dialog :title="`${emptyBarrelTitle}登记`" :visible.sync="emptyBarrelDialogVisible" width="500px" @close="depositClose">
      <el-form ref="emptyBarrelRef" :rules="emptyBarrelRules" :model="emptyBarrelForm" label-width="80px">
        <el-form-item label="商品名称" prop="name">
          <search-options v-if="emptyBarrelSearch" :tips-text="'请选择商品名称'" :options-style="'width: 80%'" :request="'product'" :fixed-params="productParams" @getAllData="queryProduct" />
        </el-form-item>
        <el-form-item :label="`${emptyBarrelTitle}数量`" prop="quantity">
          <el-input v-model="emptyBarrelForm.quantity" style="width: 80%" type="Number" clearable />
        </el-form-item>
        <el-form-item label="备注" prop="memo">
          <el-input v-model="emptyBarrelForm.memo" style="width: 80%" clearable />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button @click="emptyBarrelDialogVisible = false">取 消</el-button>
        <el-button type="primary" @click="emptyBarrelClick('emptyBarrelRef')">确 定</el-button>
      </div>
    </el-dialog>
    <el-dialog v-if="receiverAddShow" title="新增地址" :visible.sync="receiverAddVisible" width="700px" height="500px" append-to-body :before-close="receiverAddClose">
      <div style="position: relative;height:70vh;">
        <receiverAdd path-type="0" :member-id="id" @orderReceiver="receivedAddReceiver" />
      </div>
    </el-dialog>
    <el-dialog v-if="receiverEditShow" title="修改地址" :visible.sync="receiverEditVisible" width="700px" height="500px" append-to-body :before-close="receiverEditClose">
      <div style="position: relative;height: 70vh;overflow: auto">
        <receiverEdit  v-if="receiverEditVisible" :id="receivedId" path-type="0" :member-id="id" @orderReceiver="receivedEditReceiver" />
      </div>
    </el-dialog>
    <el-dialog
      title="选择商品"
      :visible.sync="orderVisible"
      width="950px"
      :before-close="orderClose">
      <div style="position: relative;">
        <productTable ref="productList"  @doubleClick="doubleClick" @addClick="addClick"></productTable>
      </div>
    </el-dialog>
      <el-dialog
        :title="wallettype"
        :visible.sync="walletstatusVisible"
         width="850px"
        :before-close="walletstatusVisibleClose">
        <div class="report_header" ref="headerHeight">
            <div style="display: flex;justify-content: space-between;align-items: center;" class="report_header" ref="headerHeight">
              <div style="display: flex;align-items: center">
                <div class="report_header_left"></div>
                <div class="report_header_date">
                  <el-date-picker style="width: 100%" v-model="date" value-format="yyyy-MM-dd" type="daterange" align="right"
                                  unlink-panels @change="changeTime" range-separator="至" start-placeholder="开始日期" end-placeholder="结束日期">
                  </el-date-picker>
                </div>
                <div v-if="walletstatus==0" style="margin-left: 20px;margin-top: 5px" class="report_header_query">
                  <el-select  clearable v-model="query.type" placeholder="类型">
                    <el-option label="收入" value="0"/>
                    <el-option label="付款" value="1"/>
                    <el-option label="退款" value="2"/>
                    <el-option label="提现" value="3"/>
                  </el-select>
                </div>
                <div v-if="walletstatus==3||walletstatus==5||walletstatus==7" style="margin-left: 20px;margin-top: 5px" class="report_header_query">
                  <el-select clearable v-model="query.type" placeholder="类型">
                    <el-option label="充值" value="0"/>
                    <el-option label="消费" value="1"/>
                    <el-option label="退款" value="2"/>
                  </el-select>
                </div>
                <div v-if="walletstatus==1" style="margin-left: 20px;margin-top: 5px" class="report_header_query">
                  <el-select clearable v-model="query.type" placeholder="类型">
                    <el-option label="获取" value="0"/>
                    <el-option label="消费" value="1"/>
                    <el-option label="退款" value="2"/>
                  </el-select>
                </div>
                <div v-if="walletstatus==2" style="margin-left: 20px;margin-top: 5px" class="report_header_query">
                  <el-select clearable v-model="query.type" placeholder="账单类型">
                    <el-option label="充值" value="0"/>
                    <el-option label="付款" value="1"/>
                    <el-option label="退款" value="2"/>
                  </el-select>
                </div>
                <div v-if="walletstatus==6" style="margin-left: 20px;margin-top: 5px" class="report_header_query">
                  <el-select clearable v-model="query.type" placeholder="单据类型">
                    <el-option label="采购单" value="0"/>
                    <el-option label="退货单" value="1"/>
                  </el-select>
                </div>
                <div v-if="walletstatus==4" style="margin-left: 20px;margin-top: 5px" class="report_header_query">
                  <el-select clearable v-model="query.type" placeholder="优惠方式">
                    <el-option label="满减券" value="0"/>
                    <el-option label="折扣券" value="1"/>
                    <el-option label="兑换券" value="3"/>
                  </el-select>
                </div>
              </div>
              <div>
                <el-button style="margin-left: 10px;margin-right: 10px;padding-top: 5px" size="small" type="primary" @click="queryClick">查询</el-button>
              </div>
            </div>
        </div>
        <div style="position: relative;" v-if="walletstatus==0">
           <el-table :data="pointList" border stripe style="width: 100%;">
             <el-table-column label="序号" type="index" width="50" align="center" />
             <el-table-column label="创建时间" align="left" width="170">
               <template slot-scope="scope">
                 <span style="margin-left: 10px">{{ scope.row.createDate | datetimeFormatter }}</span>
               </template>
             </el-table-column>
             <el-table-column label="摘要" align="left" prop="memo" />
             <el-table-column label="余额" align="left" width="110">
               <template slot-scope="scope">
                 <span style="margin-left: 10px">{{ scope.row.balance / 100 }}</span>
               </template>
             </el-table-column>
             <el-table-column label="收入" align="left" width="110">
               <template slot-scope="scope">
                 <span style="margin-left: 10px">{{ scope.row.credit / 100 }}</span>
               </template>
             </el-table-column>
             <el-table-column label="支出" align="left" width="110">
               <template slot-scope="scope">
                 <span style="margin-left: 10px">{{ scope.row.debit / 100 }}</span>
               </template>
             </el-table-column>
           </el-table>
          <el-pagination
            v-if="pointList.length>0"
            style="padding-top: 15px;"
            :current-page="pageNum"
            :page-sizes="[5, 10, 15, 20]"
            :page-size="pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="total"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
          />
      </div>
         <div style="position: relative;"  v-if="walletstatus==1">
           <el-table :data="matchPointForm" border stripe style="width: 100%;">
             <el-table-column label="序号" type="index" width="50" align="center" />
             <el-table-column label="创建时间" align="left" width="170">
               <template slot-scope="scope">
                 <span style="margin-left: 10px">{{ scope.row.createDate | datetimeFormatter }}</span>
               </template>
             </el-table-column>
             <el-table-column label="摘要" align="left" prop="memo" />
             <el-table-column label="余额" align="left" prop="balance" width="110" />
             <el-table-column label="收入" align="center" prop="credit" width="110" />
             <el-table-column label="支出" align="left" prop="debit" width="110" />
           </el-table>
          <el-pagination
            v-if="matchPointForm.length > 0"
            style="padding-top: 15px;"
            :current-page="pageNum"
            :page-sizes="[5, 10, 15, 20]"
            :page-size="pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="total"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
          />
       </div>
         <div style="position: relative;"  v-if="walletstatus==2">
           <el-table :data="depositFrom" border stripe style="width: 100%;">
             <el-table-column label="序号" type="index" width="50" align="center" />
             <el-table-column label="创建时间" align="left" width="170">
               <template slot-scope="scope">
                 <span style="margin-left: 10px">{{ scope.row.createDate | datetimeFormatter }}</span>
               </template>
             </el-table-column>
             <el-table-column label="摘要" align="left" prop="memo" />
             <el-table-column label="余额" align="left" prop="balance" width="110" />
             <el-table-column label="收入" align="center" prop="credit" width="110" />
             <el-table-column label="支出" align="left" prop="debit" width="110" />
             <el-table-column label="状态" align="left" width="110">
               <template slot-scope="scope">
                 <span style="margin-left: 10px">{{ scope.row.status | depositStatus }}</span>
               </template>
             </el-table-column>
           </el-table>
          <el-pagination
            v-if="depositFrom.length> 0"
            style="padding-top: 15px;"
            :current-page="pageNum"
            :page-sizes="[5, 10, 15, 20]"
            :page-size="pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="total"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
          />
         </div>
         <div style="position: relative;"  v-if="walletstatus==3">
            <el-table :data="cardBillList" border stripe style="width: 100%">
              <el-table-column label="序号" type="index" width="50" align="center" />
              <el-table-column label="创建日期" align="left" prop="dateFormatter" width="180">
                <template slot-scope="scope">
                  {{ scope.row.createDate | datetimeFormatter }}
                </template>
              </el-table-column>
              <el-table-column label="摘要" align="left" prop="memo" />
              <el-table-column label="余额" align="left" prop="balance" width="110" />
              <el-table-column label="收入" align="center" prop="credit" width="110" />
              <el-table-column label="支出" align="left" prop="debit" width="110" />
            </el-table>
            <el-pagination
            v-if="cardBillList.length> 0"
            style="padding-top: 15px;"
            :current-page="pageNum"
            :page-sizes="[5, 10, 15, 20]"
            :page-size="pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="total"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
          />
         </div>
         <div style="position: relative;"  v-if="walletstatus==4">
          <el-table :data="couponList" border stripe style="width: 100%">
              <el-table-column label="序号" type="index" width="50" align="center" />
              <el-table-column label="创建时间" align="left" width="170">
                <template slot-scope="scope">
                  <span style="margin-left: 10px">{{ scope.row.createDate | datetimeFormatter }}</span>
                </template>
              </el-table-column>
              <el-table-column label="名称" align="left" prop="name" min-width="250" />
              <el-table-column label="类型" align="left">
                <template slot-scope="scope">
                  {{ scope.row.type | watchType }}
                </template>
              </el-table-column>
              <el-table-column label="适用范围" align="right" prop="stock" width="80">
                <template slot-scope="scope">
                  {{ scope.row.scope | watchScope }}
                </template>
              </el-table-column>
              <el-table-column label="开始时间" align="center" width="170">
                <template slot-scope="scope">
                  <span style="margin-left: 10px">{{ scope.row.beginDate | datetimeFormatter }}</span>
                </template>
              </el-table-column>
              <el-table-column label="结束时间" align="center" width="170">
                <template slot-scope="scope">
                  <span style="margin-left: 10px">{{ scope.row.endDate | datetimeFormatter }}</span>
                </template>
              </el-table-column>
            </el-table>
                 <el-pagination
            v-if="couponList.length> 0"
            style="padding-top: 15px;"
            :current-page="pageNum"
            :page-sizes="[5, 10, 15, 20]"
            :page-size="pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="total"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
          />
         </div>
          <div style="position: relative;"  v-if="walletstatus==5">
            <el-table :data="welfareList" border stripe style="width: 100%">
              <el-table-column label="序号" type="index" width="50" align="center" />
              <el-table-column label="创建时间" align="left" width="170">
                <template slot-scope="scope">
                  <span style="margin-left: 10px">{{ scope.row.createDate | datetimeFormatter }}</span>
                </template>
              </el-table-column>
              <el-table-column label="公司名称" align="left" prop="companyName" min-width="200" />
              <el-table-column label="卡号" align="left" prop="code" min-width="200" />
              <el-table-column label="摘要" align="left" prop="memo" min-width="200" />
              <el-table-column label="结束时间" align="center" width="170">
                <template slot-scope="scope">
                  <span style="margin-left: 10px">{{ scope.row.endDate | datetimeFormatter }}</span>
                </template>
              </el-table-column>
              <el-table-column label="查看账单" align="center" width="160">
                <template slot-scope="scope">
                  <el-button type="primary" size="mini" @click="toWelfareClick(scope.row)">
                    查看账单
                  </el-button>
                </template>
              </el-table-column>
            </el-table>
            <el-pagination
            v-if="couponList.length> 0"
            style="padding-top: 15px;"
            :current-page="pageNum"
            :page-sizes="[5, 10, 15, 20]"
            :page-size="pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="total"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
          />
         </div>
          <div style="position: relative;"  v-if="walletstatus==6">
          <el-table :data="waterList" border stripe style="width: 100%">
            <el-table-column label="序号" type="index" width="50" align="center" />
            <el-table-column label="缩略图" align="left" prop="thumbnail" width="80">
              <template slot-scope="scope">
                <img :src="scope.row.thumbnail" style="width: 50px; vertical-align:middle; overflow: hidden;">
              </template>
            </el-table-column>
            <el-table-column label="水票名称" align="left" prop="name" />
            <el-table-column label="剩余张数" align="right" prop="stock" width="100" />
            <el-table-column label="说明" align="center">
              <template>
                <div class="coupon-couponList-port2-text3">有限期永久有效</div>
              </template>
            </el-table-column>
          </el-table>
          <el-pagination
          v-if="waterList.length> 0"
          style="padding-top: 15px;"
          :current-page="pageNum"
          :page-sizes="[5, 10, 15, 20]"
          :page-size="pageSize"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total"
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
        />
       </div>
          <div style="position: relative;"  v-if="walletstatus==7">
            <el-table :data="groupbuy" border stripe style="width: 100%;">
              <el-table-column label="序号" type="index" width="50" align="center" />
              <el-table-column label="创建时间" align="left" width="170">
                <template slot-scope="scope">
                  <span style="margin-left: 10px">{{ scope.row.createDate | datetimeFormatter }}</span>
                </template>
              </el-table-column>
                <el-table-column label="摘要" align="left" prop="memo" />
                <el-table-column label="余额" align="left" prop="balance" width="110" />
                <el-table-column label="收入" align="center" prop="credit" width="110" />
                <el-table-column label="支出" align="left" prop="debit" width="110" />
            </el-table>
            <el-pagination
              v-if="groupbuy.length> 0"
              style="padding-top: 15px;"
            :current-page="pageNum"
            :page-sizes="[5, 10, 15, 20]"
            :page-size="pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="total"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
          />
         </div>
          <div style="position: relative;"  v-if="walletstatus==8">
            <el-table :data="groupbuy" border stripe style="width: 100%;">
              <el-table-column label="序号" type="index" width="50" align="center" />
              <el-table-column label="创建时间" align="left" width="170">
                <template slot-scope="scope">
                  <span style="margin-left: 10px">{{ scope.row.createDate | datetimeFormatter }}</span>
                </template>
              </el-table-column>
              <el-table-column label="摘要" align="left" prop="memo" />
              <el-table-column label="余额" align="left" prop="balance" width="110" />
              <el-table-column label="收入" align="center" prop="credit" width="110" />
              <el-table-column label="支出" align="left" prop="debit" width="110" />
            </el-table>
            <el-pagination
              v-if="groupbuy.length> 0"
              style="padding-top: 15px;"
              :current-page="pageNum"
              :page-sizes="[5, 10, 15, 20]"
              :page-size="pageSize"
              layout="total, sizes, prev, pager, next, jumper"
              :total="total"
              @size-change="handleSizeChange"
              @current-change="handleCurrentChange"
            />
          </div>
          <div style="position: relative;"  v-if="walletstatus==9">
            <el-table :data="groupbuy" border stripe style="width: 100%;">
              <el-table-column label="序号" type="index" width="50" align="center" />
              <el-table-column label="创建时间" align="left" width="170">
                <template slot-scope="scope">
                  <span style="margin-left: 10px">{{ scope.row.createDate | datetimeFormatter }}</span>
                </template>
              </el-table-column>
              <el-table-column label="摘要" align="left" prop="memo" />
              <el-table-column label="余额" align="left" prop="balance" width="110" />
              <el-table-column label="收入" align="center" prop="credit" width="110" />
              <el-table-column label="支出" align="left" prop="debit" width="110" />
            </el-table>
            <el-pagination
              v-if="groupbuy.length> 0"
              style="padding-top: 15px;"
              :current-page="pageNum"
              :page-sizes="[5, 10, 15, 20]"
              :page-size="pageSize"
              layout="total, sizes, prev, pager, next, jumper"
              :total="total"
              @size-change="handleSizeChange"
              @current-change="handleCurrentChange"
            />
          </div>
          <div style="position: relative;"  v-if="walletstatus==10">
            <el-table :data="groupbuy" border stripe style="width: 100%;">
              <el-table-column label="序号" type="index" width="50" align="center" />
              <el-table-column label="创建时间" align="left" width="170">
                <template slot-scope="scope">
                  <span style="margin-left: 10px">{{ scope.row.createDate | datetimeFormatter }}</span>
                </template>
              </el-table-column>
              <el-table-column label="摘要" align="left" prop="memo" />
              <el-table-column label="余额" align="left" prop="balance" width="110" />
              <el-table-column label="收入" align="center" prop="credit" width="110" />
              <el-table-column label="支出" align="left" prop="debit" width="110" />
            </el-table>
            <el-pagination
              v-if="groupbuy.length> 0"
              style="padding-top: 15px;"
              :current-page="pageNum"
              :page-sizes="[5, 10, 15, 20]"
              :page-size="pageSize"
              layout="total, sizes, prev, pager, next, jumper"
              :total="total"
              @size-change="handleSizeChange"
              @current-change="handleCurrentChange"
            />
          </div>
        <div style="position: relative;"  v-if="walletstatus==11">
          <el-table :data="groupbuy" border stripe style="width: 100%;">
            <el-table-column label="序号" type="index" width="50" align="center" />
            <el-table-column label="创建时间" align="left" width="170">
              <template slot-scope="scope">
                <span style="margin-left: 10px">{{ scope.row.createDate | datetimeFormatter }}</span>
              </template>
            </el-table-column>
            <el-table-column label="摘要" align="left" prop="memo" />
            <el-table-column label="余额" align="left" prop="balance" width="110" />
            <el-table-column label="收入" align="center" prop="credit" width="110" />
            <el-table-column label="支出" align="left" prop="debit" width="110" />
          </el-table>
          <el-pagination
            v-if="groupbuy.length> 0"
            style="padding-top: 15px;"
            :current-page="pageNum"
            :page-sizes="[5, 10, 15, 20]"
            :page-size="pageSize"
            layout="total, sizes, prev, pager, next, jumper"
            :total="total"
            @size-change="handleSizeChange"
            @current-change="handleCurrentChange"
          />
        </div>
      </el-dialog>
    <rechargeDialog :memberId="id" ref='rechargeDialog' @loadOrder="rechargeDialogEvent" ></rechargeDialog>
    <dividendBond :memberId="id" ref='dividendBondDialog' @loadOrder="rechargeDialogEvent" ></dividendBond>
  </div>
</template>
<style scoped lang="scss">
  .menu-wrapper {
    margin: 15px;
  }
  .box-card {
    width: 100%;
    box-sizing: border-box;
  }
  .deleted_OrderContent {
    margin-top: 20px;
    display: flex;
    flex-direction: row;
    align-items: center;
  }
  .deleted_Row_Headings {
    display: inline-block;
    width:96px;
    color: #666666;
  }
  .deleted_OrderHeader {
    padding-top: 5px;
    padding-bottom: 10px;
    margin: 10px 0;
    border-left: 1px solid #f2f2f2;
    border-bottom: 1px solid #f2f2f2;
  }

  .details_card {
    overflow: auto;
    padding-left: 20px;
    padding-right: 20px;
    box-sizing: border-box;
    border: 1px solid #f2f2f2;
    border-radius: 4px;}
  .details_card:hover {
    box-shadow: 0 2px 4px rgba(0, 0, 0, .12), 0 0 6px rgba(0, 0, 0, .04)
  }
  .elOption{
    color:white ;
    text-align: center;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 50%;
    height: 40px;
  }
  .deleted_OrderTitle_app{
    cursor: pointer;
    color: rgb(70,166,255);
  }
  .deleted_OrderTitle_changedisplay{
    display: inline-block;
    width: 50px;
  }
  .report_header_date {
    width: 250px;
    padding-left: 10px;
    padding-top: 5px;
  }
  .report_header_left {
    width: 5px;
    height: 46px;
    background-color: #409EFF;
    position: absolute;
    top: 0;
    bottom: 0;
    left: 0;
  }
  .report_header {
    display: flex;
    position: relative;
    margin-bottom: 10px;
    width: 100%;
    min-height: 40px;
    box-sizing: border-box;
    background-color: rgba(248, 248, 248, 0.8);
  }
  /deep/ .el-dialog__body{
    padding-top: 0px!important;
  }
</style>
<script>

import rechargeDialog from '@/components/Recharge/recharge'
import dividendBond from '@/components/Recharge/dividendBond'
import loadMore from '@/utils/loadMore.js'
import permission from '@/directive/permission/index.js' // 权限判断指令
import utils from '../../utils/utils.js'
import searchOptions from '@/components/searchOptions'
import { find, point, receiver, transfer } from '@/api/member'
import { list as sysMchList } from '@/api/sysMch'
import { del as receiverDel } from '@/api/receiver'
import { addEmptyBarrel, decEmptyBarrel, emptyBarrel, summary } from '@/api/emptyBarrel'
import {summary as summarys} from  '@/api/card'
import { list as virtualStock } from '@/api/virtualStock.js'
import {add,dec} from '@/api/virtualProduct'
import memberList from '../member/component/list'
import {  list as shopping } from '@/api/order'
import { list as coupon } from '@/api/couponCode'
import { list as payment } from '@/api/payment'
import { list as refund } from '@/api/refunds'
import { list as card } from '@/api/card'
import { cardBillList as cardbill } from '@/api/cardBill'
import receiverAdd from '@/views/receiver/add'
import receiverEdit from '@/views/receiver/edit'
import {list as matchPointList} from '@/api/matchPoint'
import { list } from '@/api/product'
import { mapGetters } from 'vuex'
import { EventBus } from '@/api/eventBus'
import { list as market,save as saveMarket,del as delMarket,update as updateMarket} from '@/api/productPrice'
import { list as depositList} from '@/api/deposit'
import productTable from '@/components/ProductList/productList'


export default {
  // name: 'member-edit',
  directives: { permission, loadMore },
  components: { searchOptions, receiverAdd, receiverEdit,memberList, productTable,rechargeDialog,dividendBond},
  filters: {
    watchPayment(val) {
      if (val == 'cashPayPlugin') {
        return '现金'
      } else if (val == 'debtPayPlugin') {
        return '月结'
      } else if (val == 'salePayPlugin') {
        return '代销'
      }
    },
    watchScope(val) {
      if (val == 0) {
        return '全场'
      } else if (val == 1) {
        return '店内'
      } else if (val == 2) {
        return '商城'
      }
    },
    watchType(val) {
      if (val == 0) {
        return '满减'
      } else if (val == 1) {
        return '满折'
      } else if (val == 2) {
        return '满赠'
      } else if (val == 3) {
        return '兑换券'
      }
    },
    orderFormatter(val) {
      if (val == 0) {
        return '未确认'
      } else if (val == 1) {
        return '已确认'
      } else if (val == 2) {
        return '已完成'
      } else if (val == 3) {
        return '已取消'
      } else if (val == 4) {
        return '已评价'
      }
    },
    shippingFormatter(val) {
      if (val == 0) {
        return '未发货'
      } else if (val == 1) {
        return '已发货'
      } else if (val == 2) {
        return '待退货'
      } else if (val == 3) {
        return '已退货'
      }
    },
    watchStatus(val) {
      if (val == 0) {
        return '等待支付'
      } else if (val == 1) {
        return '支付成功'
      } else if (val == 2) {
        return '超时关闭'
      } else if (val == 3) {
        return '支付失败'
      }
    },
    depositStatus(val){
      if (val == 0) {
        return '待审核'
      } else if (val == 1) {
        return '已确认'
      } else if (val == 2) {
        return '已完成'
      } else if (val == 3) {
        return '已关闭'
      }
    }
  },
  data() {
    return {
      date: [],
      query: {
        type:'',
        subType:'',
        cardType:'',
        endDate: '',
        beginDate: ''
      },
      idCardNoState:'',
      realNameStatus:'',
      realNameInfo:null,
      Invitationcode:"",
      walletstatusVisible:false,
      wallettype:"",
      walletstatus:"",
      tabsHeight: null,
      orderForm:[],
      productTongName:'',
      TongProduct:{},
      productName:'',
      options:{},
      barrelsNumber:'',
      obbitem:{
        productId:'',
        quality:'',
        emptyBarrelId:''
      },
      isType:'',
      shopName:'无',
      mchIdMark: false,
      returnVisible:false,
      products:[],
      emptyBarrelNum: 0,
      price: 0,
      stock: 0,
      id: '',
      bomTile:'',
      receivedId: '',
      activeName: 'otherInfo',
      path: 'otherInfo',
      payLoads: '',
      promoterName: '',
      managerName:'',
      dialogTableVisible: false,
      dialogFourleVisible: false,
      marketForm:[],
      form: {
        balance: 0,
        point: 0,
        name: '',
        birth: '',
        mobile: '',
        phone: '',
        email: '',
        gender: '0',
        areaId: 440000,
        areaName: '广东省广州市海珠区',
        address: '',
        vip: '',
        memberCategoryId: '',
        memberType: '0'
      },
      vipName: '',
      memberCategoryName: '',
      optionsForm: [
        { name: '男', value: 1 },
        { name: '女', value: 2 }
      ],
      receiverList: [],
      emptyBarrelList: [],
      emptyBarrelShow: false,
      depositList: [],
      pointList: [],
      waterList: [],
      plegdeList: [],
      waterShow: false,
      shoppingList: [],
      shoppingShow: false,
      paymentList: [],
      payments:[{
        name:'转账(现金已收)',
        paymentPluginId:'bankPayPlugin',
      },
      {
        name:'欠款(财务结款)',
        paymentPluginId:'debtPayPlugin',
      }],
      emptyBarrelMany:0,
      emptyBarrelLess:0,
      paymentPluginId:'',
      paymentShow: false,
      refundList: [],
      refundShow: false,
      groupbuy:[],
      welfareList: [],
      couponList: [],
      matchPointForm: [],
      depositFrom:[],
      couponShow: false,
      cardBillList: [],
      rechargeShow: false,
      pageSize: 5,
      pageNum: 1,
      total: 0,
      paginationShow: false,
      requestList: '',
      receiverAddVisible: false,
      receiverAddShow: false,
      receiverEditVisible: false,
      receiverEditShow: false,
      emptyBarrelSearch: false,
      emptyBarrelTitle: '',
      emptyBarrelDialogVisible: false,
      emptyBarrelForm: {},
      productParams: {
        'subType': 4,
        'type': 0,
        'isList': true
      },
      transferRules: {
        mchId: [
          { required: true, message: '请选择商户名称', trigger: 'blur' }
        ]
      },
      emptyBarrelRules: {
        name: [
          { required: true, message: '请选择商品名称', trigger: 'blur' }
        ],
        quantity: [
          { required: true, message: '请输入数量', trigger: 'blur' }
        ],
        memo: [
          { required: true, message: '请输入备注', trigger: 'blur' }
        ]
      },
      productForm:[],
      productTitle:'',
      productItem:null,
      visibleMarket:false,
      priceMarket:'0',
      saveMarketLoading:false,
      delMarketLoading:false,
      updateMarketLoading:false,
      balance:0,
      orderVisible: false,
      productList: [],
      bindingImage:'',
      waterVisible:false,
      cardVo:{},
      virtualStockNum:{},
      cardBalance:0, //团购卷
      groupBuy: 0,  //会员卡
      couponCodeNum:0 ,//优惠卷数量
      virtualStock: 0 ,//水票数量
      benefits:0, //福利卡
      stockRight:0 //分红股权

    }
  },
  activated() {
    this.payLoads = new Date().getTime()
  },
  created() {
    this.getData()
      var _this = this
    this.loadOrder()
    EventBus.$on('order-add', res => { // 监听新增完毕
        // 更新列表数组
        _this.orderForm.splice(0, 0, res)
      })
      EventBus.$on('order-edit', res => { // 监听状态更新
        // 更新列表数组
        for (var i = 0; i < _this.orderForm.length; i++) {
          if (_this.orderForm[i].id == res.id) {
            _this.$set(this.orderForm, i, res)
          }
        }
      })
      EventBus.$on('order-delete', res => { // 监听订单删除
      })
      EventBus.$on('order-view', res => { // 监听订单删除
        // 更新列表数组
        for (var i = 0; i < _this.orderForm.length; i++) {
          if (_this.orderForm[i].id == res.id) {
            _this.$set(this.orderForm, i, res)
          }
        }
      })
  },
  computed: {
    ...mapGetters([
      'scopeType','mchId'
    ])
  },
  methods: {
    clearDate() {
      this.date = []
      this.query.beginDate = ""
      this.query.endDate = ""
      this.query.type = ""
      console.log(this.date,"1321321211111111")
    },
    changeTime(data) {
      if (!utils.isNull(data)) {
        if (data.length > 1) {
          this.query.beginDate = data[0]
          this.query.endDate = data[1]
        }
      } else {
        this.query.beginDate = ''
        this.query.endDate = ''
      }
      this.queryDateClick(this.query)
    },
    queryDateClick(data) {
      this.query.beginDate = data.beginDate
      this.query.endDate = data.endDate
    },
    queryClick() {
      this.pageNum = 1
      this.pointClick(this.walletstatus)
    },
    rechargeDialogEvent(){
      new Promise((resolve, reject) => {
        this.getData()
        resolve()
      }).then(() => {
          this.activeName = "wallet"
        })
    },
    Rechargeclick(rechargeType){
      console.log(rechargeType)
      this.$refs.rechargeDialog.Rechargeclick(rechargeType);
    },
    dividendBond(dividendBondType){
      console.log(dividendBondType)
      this.$refs.dividendBondDialog.Rechargeclick(dividendBondType);
    },
    Invitationcodeclick(){
      if(!utils.isNull(this.form.userId)){
        let poctio = 'http://g'+this.mchId+'.rzico.com/q/'+this.form.userId
         this.Invitationcode = process.env.VUE_APP_BASE_API + '/zxing/createImage?data=' + encodeURIComponent(poctio)
      }
    },
    waterVisibshow(){
       let poctio = 'http://g'+this.mchId+'.rzico.com/q/90'+this.form.code
       this.bindingImage = process.env.VUE_APP_BASE_API + '/zxing/createImage?data=' + encodeURIComponent(poctio)
       this.waterVisible=true
    },
    waterVisibleClose(){
      this.waterVisible=false
    },
    editClick() {
      this.$router.push({
        path: '/member/edit', query: { id:this.id}
      })
    },
    productTongNamechang(val){
   this.obbitem.emptyBarrelId=val.id
    },
    productIdchang(val){
      console.log(val);
     this.barrelsNumber=val
      this.obbitem.productId=val.id
      this.productName=val.name

    },
   walletstatusVisibleClose(){
     this.walletstatusVisible=false
     this.clearDate()
   },

    pointClick(event){
      console.log(event,"eventeventeventeventeventevent")
     this.walletstatusVisible=true
     this.walletstatus=event
     switch(event) {
      case 0:
        this.wallettype='红包金额'
        this.initPoint()
        this.requestList = 'initPoint'
        break;
     case 1:
        this.wallettype='购物券余额'
        this.initMatchPoint()
        this.requestList = 'initMatchPoint'
        break;
     case 2:
        this.wallettype='钱包余额'
        this.initDepositList()
       this.requestList = 'initDepositList'
        break;
     case 3:
        this.wallettype='会员卡'
        this.initcard()
        this.requestList = 'initcard'
        break;
     case 4:
        this.wallettype='优惠卷'
          this.initCoupon()
        this.requestList = 'initCoupon'
        break;
     case 5:
        this.wallettype='福利卡'
        this.initwelfare()
        this.requestList = 'initwelfare'
        break;
     case 6:
        this.wallettype='电子水票'
        this.initWater()
        this.requestList = 'initWater'
        break;
     case 7:
        this.wallettype='兑换券'
        this.iniGroupbu()
        this.requestList = 'iniGroupbu'
        break;

     }
    },
    selectBom(){

        if(this.paymentPluginId!=''){
            if (this.obbitem.quality!=''){
              var param=new URLSearchParams()
              param.append('memberId',this.form.id)
              param.append('productId', this.obbitem.productId)
              param.append('quantity',this.obbitem.quality)
              param.append('paymentPluginId',this.paymentPluginId)
              param.append('emptyBarrelId',this.obbitem.emptyBarrelId)
              if (this.isType=='add'){
                add(param).then(res=>{
                  if(res.type=='success'){
                    this.$message({
                      message: '成功',
                      type: 'success'
                    });
                    this.returnVisible=false
                    this.initPlegde()
                    this.initEmptyBarrel()
                  }
                })
              }else if(this.isType=='return'){
                dec(param).then(res=>{
                  if(res.type=='success'){
                    this.$message({
                      message: '成功',
                      type: 'success'
                    });
                    this.returnVisible=false
                    this.initPlegde()
                    this.initEmptyBarrel()
                  }
                })
              }
            }
        }else if(this.paymentPluginId==''){
          this.$message({
            message: '请选择收款方式',
            type: 'warning'
          });
        }
    },
    loadOrder() {
      var _this = this
      const params = {
        memberId: this.id,
        pageSize: this.pageSize,
        pageNum: this.pageNum
      }
      shopping(params).then(response => {
        console.log(response,'消费')
        _this.orderForm = response.data.data
        _this.total = response.data.total
      }).catch(error => {
        console.log('error!!')
      })
    },
    loadProduct(){
      list({
        subType: 3,
        type: 1
      }).then(res=>{
        res.data.data.forEach(item=>{
          item.quality=0
        })
        this.products=res.data.data
      })
    },

     loadTongProduct(){
      list({
        subType: 4,
      }).then(res=>{

        this.TongProduct=res.data.data

      })
    },
    memberReturnClick(){
      this.paymentPluginId=''
      this.productTongName=" "
      this.productName=" "
      this.barrelsNumber={}
      this.obbitem.productId=' ',
      this.obbitem.quality=' ',
      this.obbitem.emptyBarrelId=' ',
      this.loadTongProduct()
      this.loadProduct()
      this.isType='return'
      this.returnVisible=true
      this.bomTile='退桶'
    },
    memberAddClick(){
      this.paymentPluginId=''
      this.productTongName=" "
      this.productName=" "
      this.barrelsNumber={}
      this.obbitem.productId=' ',
      this.obbitem.quality=' ',
      this.obbitem.emptyBarrelId=' ',
      this.loadTongProduct()
      this.loadProduct()
      this.isType='add'
      this.returnVisible=true
      this.bomTile='押桶'
    },


    getData() {
      this.activeName = 'otherInfo'
      this.id = this.$route.query.id
      find(this.id).then(response => {
        if (response.type === 'success') {
          this.form.id = this.$route.query.id
          this.form = response.data.member
          this.balance = response.data.balance
          this.shopName=response.data.shopName
          this.promoterName = response.data.promoterName
          this.managerName = response.data.managerName
          this.couponCodeNum = response.data.couponCodeNum
          this.cardBalance = response.data.cardBalance
          this.groupBuy = response.data.groupBuy
          this.virtualStock = response.data.virtualStock
          this.benefits= response.data.benefits
          this.stockRight = this.form.stockRight
          this.realNameStatus = response.data.sysUser.realNameStatus
           if(response.data.sysUser.realNameInfo){
             this.realNameInfo =  JSON.parse(response.data.sysUser.realNameInfo);
           }
           if(this.realNameInfo.bankCardNo){
             this.idCardNoState = this.realNameInfo.bankCardNo.substring(0, 2)
           }
//          this.initTabData()
        } else {
          this.$message({ message: response.content, offset: 120, center: true })
        }
      }).catch(err => { console.log(err) })
    },
//    initTabData() {
//      this.initReceiver()
//      this.initPoint()
//      this.initMatchPoint()
//      this.initDepositList()
//      this.waterVisibshow()
//      this.Invitationcodeclick()
//    },
    initReceiver() {
      const params = {
        memberId: this.id,
        pageSize: this.pageSize,
        pageNum: this.pageNum
      }
      receiver(params).then(res => {
        this.receiverList = res.data.data
        this.total = res.data.total
      }).catch(err => { console.log(err) })
    },
    initPoint() {
      const params = {
        memberId: this.id,
        pageSize: this.pageSize,
        pageNum: this.pageNum,
        startDate:this.query.beginDate,
        endDate:this.query.endDate,
        type:this.query.type
      }
      point(params).then(res => {
        console.log(res, '金币')
        this.pointList = res.data.data
        this.total = res.data.total
      }).catch(err => { console.log(err) })
    },
    initWater() {
      const params = {
        memberId: this.id,
        pageSize: this.pageSize,
        pageNum: this.pageNum,
        subType: 2,
        startDate:this.query.beginDate,
        endDate:this.query.endDate,
        type:this.query.type
      }
      virtualStock(params).then(res => {
        this.total = res.data.total
        res.data.data.forEach(item => {
          item.stock = parseInt(item.stock)
          item.price = parseFloat(item.price).toFixed(2)
        })
        this.waterList = res.data.data
      }).catch(err => { console.log(err) })
    },
    initPlegde() {
      const params = {
        memberId: this.id,
        pageSize: this.pageSize,
        pageNum: this.pageNum,
        subType: 3,
        startDate:this.query.beginDate,
        endDate:this.query.endDate,
        type:this.query.type
      }
      virtualStock(params).then(res => {
        this.plegdeList = res.data.data
      }).catch(err => { console.log(err) })
    },
    initEmptyBarrel() {
      const params = {
        memberId: this.id,
        pageSize: this.pageSize,
        pageNum: this.pageNum,
        subType: 3
      }
      emptyBarrel(params).then(res => {
        this.total = res.data.total
        this.emptyBarrelList = res.data.data
        this.initSummary()
      }).catch(err => { console.log(err) })
    },
    initSummary() {
      summary({ memberId: this.id }).then(res => {
        this.emptyBarrelNum = !utils.isNull(res.data.emptyBarrel) ? Number(res.data.emptyBarrel) : '0'
        this.price = !utils.isNull(res.data.price) ? Number(res.data.price).toFixed(2) : '0'
        this.stock = !utils.isNull(res.data.stock) ? Number(res.data.stock) : '0'
        this.emptyBarrelMany=!utils.isNull(res.data.emptyBarrelMany)?Number(res.data.emptyBarrelMany).toFixed(0):'0'
        this.emptyBarrelLess=!utils.isNull(res.data.emptyBarrelLess)?Number(res.data.emptyBarrelLess).toFixed(0):'0'
      }).catch(err => {
        console.log(err)
      })
    },
    initDeposit() {
      const params = {
        memberId: this.id,
        pageSize: this.pageSize,
        pageNum: this.pageNum,
        subType: 3,
        startDate:this.query.beginDate,
        endDate:this.query.endDate,
      }
      virtualStock(params).then(res => {
        this.total = res.data.total
        res.data.data.forEach(item => {
          item.stock = parseInt(item.stock)
          item.price = parseFloat(item.price)
          this.allStock += item.stock
          this.allPrice += item.price
        })
        this.depositList = res.data.data
        this.initSummary()
      }).catch(err => { console.log(err) })
    },
    initShopping() {
      const params = {
        memberId: this.id,
        pageSize: this.pageSize,
        pageNum: this.pageNum
      }
      shopping(params).then(res => {
        this.total = res.data.total
        this.shoppingList = res.data.data
      }).catch(err => { console.log(err) })
    },
    initPayment() {
      const params = {
        memberId: this.id,
        pageSize: this.pageSize,
        pageNum: this.pageNum
      }
      payment(params).then(res => {
        this.total = res.data.total
        this.paymentList = res.data.data
      }).catch(err => { console.log(err) })
    },
    initRefund() {
      const params = {
        memberId: this.id,
        pageSize: this.pageSize,
        pageNum: this.pageNum
      }
      refund(params).then(res => {
        this.total = res.data.total
        this.refundList = res.data.data
      }).catch(err => { console.log(err) })
    },
    initcard() {
      var _this = this
      const params = {
        memberId: this.id,
        cardType: 0,
      }
      card(params).then(res => {
        console.log(res)
        if (res.data.data.length > 0) {
          _this.initcardBill(res.data.data[0].id)
        }
      }).catch(err => { console.log(err) })
    },
    initcardBill(id) {
      const params = {
        memberId: this.id,
        pageSize: this.pageSize,
        pageNum: this.pageNum,
        cardId: id,
        startDate:this.query.beginDate,
        endDate:this.query.endDate,
        type:this.query.type
      }
      cardbill(params).then(res => {
        console.log(res)
        this.total = res.data.total
        this.cardBillList = res.data.data
      }).catch(err => { console.log(err) })
    },
    initwelfare() {
      var _this = this
      const params = {
        memberId: this.id,
        pageSize: this.pageSize,
        pageNum: this.pageNum,
        cardType: 1,
        startDate:this.query.beginDate,
        endDate:this.query.endDate,
        type:this.query.type
      }
      card(params).then(res => {
        console.log(res,'详情1')
        this.total = res.data.total
        this.welfareList = res.data.data
      }).catch(err => { console.log(err) })
    },
    iniGroupbu() {
      var _this = this
      const params = {
        memberId: this.id,
        pageSize: this.pageSize,
        pageNum: this.pageNum,
        cardType: 2,
        startDate:this.query.beginDate,
        endDate:this.query.endDate,
        type:this.query.type
      }
      cardbill(params).then(res => {
        this.total = res.data.total
        this.groupbuy = res.data.data
      }).catch(err => { console.log(err) })
    },
    initCoupon() {
      const params = {
        memberId: this.id,
        pageSize: this.pageSize,
        pageNum: this.pageNum,
        startDate:this.query.beginDate,
        endDate:this.query.endDate,
        type:this.query.type
      }
      coupon(params).then(res => {
        this.total = res.data.total
        this.couponList = res.data.data
      }).catch(err => { console.log(err) })
    },
    initMatchPoint(){
      const params = {
        memberId: this.id,
        pageSize: this.pageSize,
        pageNum: this.pageNum,
        startDate:this.query.beginDate,
        endDate:this.query.endDate,
        type:this.query.type
      }
      matchPointList(params).then(res => {
        console.log(res,'购物券')
        this.total = res.data.total
        this.matchPointForm = res.data.data
      }).catch(err => { console.log(err) })
    },
    initDepositList(){
      const params = {
        memberId: this.id,
        pageSize: this.pageSize,
        pageNum: this.pageNum,
        startDate:this.query.beginDate,
        endDate:this.query.endDate,
        type:this.query.type
      }
      depositList(params).then(res=>{
        console.log(res,'库存')
        this.total = res.data.total
        this.depositFrom = res.data.data
      }).catch(err => { console.log(err) })
    },
    receiverAddClose(){
      this.receiverAddVisible = false
    },
    receivedAddReceiver(data) {
      this.initReceiver()
      this.receiverAddShow = false
      this.receiverAddVisible = false
    },
    receiverEditClose() {
       this.receivedId=''
      this.receiverEditVisible = false
    },
    receivedEditReceiver(data) {
      this.initReceiver()
      this.receiverEditShow = false
      this.receiverEditVisible = false
    },
    queryProduct(value) {
      if (!utils.isNull(value)) {
        this.emptyBarrelForm.cost = 0
        this.emptyBarrelForm.name = value.name
        this.emptyBarrelForm.productId = value.id
        this.emptyBarrelForm.sn = value.sn
        this.emptyBarrelForm.spec = value.spec1
        this.emptyBarrelForm.thumbnail = value.thumbnail
        this.emptyBarrelForm.unit = value.unit
      } else {
        this.emptyBarrelForm.cost = null
        this.emptyBarrelForm.name = null
        this.emptyBarrelForm.productId = null
        this.emptyBarrelForm.sn = null
        this.emptyBarrelForm.spec = null
        this.emptyBarrelForm.thumbnail = null
        this.emptyBarrelForm.unit = null
      }
    },
    outDepositShow() {
      this.emptyBarrelSearch = true
      this.emptyBarrelTitle = '欠桶'
      this.emptyBarrelForm.emptyType = 1
      this.emptyBarrelDialogVisible = true
    },
    returnDepositShow() {
      this.emptyBarrelSearch = true
      this.emptyBarrelTitle = '存桶'
      this.emptyBarrelForm.emptyType = 2
      this.emptyBarrelDialogVisible = true
    },
    emptyBarrelClick(formName) {
      this.$refs[formName].validate((valid) => {
        if (valid) {
          this.emptyBarrelForm.memberId = this.id
          const obj = {}
          for (const key in this.emptyBarrelForm) {
            obj[key] = this.emptyBarrelForm[key]
          }
          const tempFrom = [obj]
          console.log(tempFrom);
          if (this.emptyBarrelTitle === '欠桶') {
            tempFrom[0].quantity = -Math.abs(tempFrom[0].quantity) // 全部转成负数避免用户输入错误
            decEmptyBarrel(tempFrom).then(res => {
              this.initEmptyBarrel()
            }).catch(err => { console.log(err) })
          } else if (this.emptyBarrelTitle === '存桶') {
            tempFrom[0].quantity = Math.abs(tempFrom[0].quantity)
            addEmptyBarrel(tempFrom).then(res => {
              this.initEmptyBarrel()
            }).catch(err => { console.log(err) })
          }
          this.emptyBarrelDialogVisible = false
        }
      })
    },
    depositClose() {
      this.emptyBarrelSearch = false
      this.emptyBarrelForm = {}
    },
    detailsClick(data) {
      this.$router.push({
        path: '/order/view', query: { id: data }
      })
    },
    toOrder(row) {
      this.$router.push({
        path: '/order/view?id=' + row.id
      })
    },
    toPayment(row) {
      this.$router.push({
        path: '/payment/view?id=' + row.id
      })
    },
    toRefund(row) {
      this.$router.push({
        path: '/refund/view', query: { id: row.id }
      })
    },
    toWelfareClick(row) {
      this.$router.push({
        path: '/member/welfareBill?id=' + row.id + '&memberId=' + this.id
      })
    },
    showAddReceiver() {
      this.receiverAddShow = true
      this.receiverAddVisible = true
    },
    showEditReceiver(row) {
      this.receivedId = row.id
      this.receiverEditShow = true
      this.receiverEditVisible = true
    },
    delAddress(row) {
      this.$confirm('确认删除?', '提示', {
        confirmButtonText: '确定',
        cancelButtonText: '取消',
        type: 'warning'
      }).then(() => {
        receiverDel(row.id).then(response => {
          console.log(response)
          receiver({ memberId: this.id }).then(res => {
            this.receiverList = res.data.data
          }).catch(err => { console.log(err) })
          this.$message({ message: response.content, offset: 120, center: true })
        }).catch(err => { console.log(err) })
      }).catch(err => { console.log(err) })
    },
    handleSizeChange(value) {
      this.pageSize = value
      this[this.requestList]()
    },
    handleCurrentChange(value) {
      this.pageNum = value
      this[this.requestList]()
    },
    tabsClick(tab, event) {
      console.log(tab, event)
      this.pageSize = 5
      this.pageNum = 1
      this.total = 0
      this.paginationShow = true
      if (tab.name === 'otherInfo') {
        this.paginationShow = false
      } else if (tab.name === 'receiver') {
        this.initReceiver()
        this.requestList = 'initReceiver'
      } else if (tab.name === 'point') {
        this.initPoint()
        this.requestList = 'initPoint'
      } else if (tab.name === 'water') {
        this.initWater()
        this.requestList = 'initWater'
      } else if (tab.name === 'emptyBarrel') {
        this.initPlegde()
        this.initEmptyBarrel()
        this.requestList = 'initEmptyBarrel'
      } else if (tab.name === 'deposit') {
        this.initDeposit()
        this.requestList = 'initDeposit'
      }else if (tab.name === 'shopping') {
        this.loadOrder()
        this.requestList = 'loadOrder'
      } else if (tab.name === 'coupon') {
        this.initCoupon()
        this.requestList = 'initCoupon'
      } else if (tab.name === 'payment') {
        this.initPayment()
        this.requestList = 'initPayment'
      } else if (tab.name === 'refunds') {
        this.initRefund()
        this.requestList = 'initRefund'
      } else if (tab.name === 'memberCard') {
        this.initcard()
        this.requestList = 'initcard'
      } else if (tab.name === 'welfare') {
        this.initwelfare()
        this.requestList = 'initwelfare'
      } else if (tab.name == 'matchPoint'){
        this.initMatchPoint()
        this.requestList = 'initMatchPoint'
      } else if (tab.name == 'market'){
        this.marketClick()
        this.requestList = 'marketClick'
      }else if (tab.name == 'depositt'){
       this.initDepositList()
        this.requestList = 'initDepositList'
      }
      else if (tab.name == 'wallet'){
        this.paginationShow = false
      }
    },
    marketClick(){
      var _this = this
      _this.loadProductClick()
      market({memberId:_this.id,      pageSize: this.pageSize, pageNum: this.pageNum}).then(res=>{
        console.log(res)
        this.total = res.data.total
        this.marketForm = res.data.data
      })
    },
    marketChoose(data){
      console.log(data)
      this.productItem = this.productForm[data]
      console.log(this.productItem)
    },
    loadProductClick(data){
      var _this = this
      list({keyword:data}).then(res=>{
        console.log(res)
        _this.productForm = res.data.data
      })
    },
    remoteMethod(data){
      console.log(data)
      this.loadProductClick(data)
    },
    creatClick(){
      this.saveMarket()
      this.productTitle = ''
    },
    saveMarket(){
      var _this = this
      if (!utils.isNull(_this.productItem)){
        if (_this.saveMarketLoading == true){
          return;
        }
        _this.saveMarketLoading = true
        saveMarket({memberId:_this.id,price:_this.productItem.price,productId:_this.productItem.id}).then(res=>{
          console.log(res)
          _this.saveMarketLoading = false
          _this.marketClick()
          _this.visibleMarket = false
        }).catch(error=>{
          _this.saveMarketLoading = false
        })
      }else {
        _this.$message({
          message: '请选择商品',
          type: 'warning'
        });
        return;
      }
    },
    delMarketClick(data){
      console.log(data)
      var _this = this
      if (_this.delMarketLoading == true){
        return
      }
      _this.delMarketLoading = true
      delMarket(data.id).then(res=>{
        console.log(res)
        _this.delMarketLoading = false
        this.marketClick()
      }).catch(error=>{
        _this.delMarketLoading = false
      })
    },
    changeMarket(data,item){
      var _this= this
      if (!utils.isNull(item.price)){
        if (_this.updateMarketLoading == true){
          return
        }
        _this.updateMarketLoading = true
        var data = {
          price:item.price,
          id:item.id
        }
        updateMarket(data).then(res=>{
          _this.updateMarketLoading = false
          _this.marketClick()
        }).catch(error=>{
          _this.updateMarketLoading = false
        })
      }else {
        item.price = this.priceMarket
      }
    },
    focusMarket(data,item){
      this.priceMarket = item.price
      console.log(data)
      console.log(item)
    },
    toAddProduct(){
      this.orderVisible = true;
    },
    doubleClick(data) {
      console.log(data)
      this.productItem = data
      this.saveMarket()
    },
    addClick(data) {
      var _this = this
      if (data.length == 0){
        this.message('请选择商品')
        return;
      }
      data.forEach((item,index) => {
        saveMarket({memberId:_this.id,price:item.price,productId:item.id}).then(res=>{
          if (index == data.length-1){
            _this.marketClick()
          }
        }).catch(error=>{

        })
      })
    },
    orderClose() {
      this.orderVisible = false;
      if (this.productList.length > 0 && this.chooseOrderName != '') {
        this.productList[this.tableIndex].name = this.chooseOrderName
      }
      this.$refs.productList.cancelClick();
    },
    procuctFilter() {
      let newfood = [];
      var temp = {};
      for (var i in this.productList) {
        if (this.productList[i].productId != '') {
          var key = this.productList[i].productId+"_"+this.productList[i].price;
          console.log(this.productList[i].price)
          if (temp[key]) {
            temp[key].productId = temp[key].productId;
            temp[key].quantity = temp[key].quantity + this.productList[i].quantity;
            temp[key].subTotal = parseFloat(this.productList[i].price) * parseFloat(temp[key].quantity);
            temp[key].amountPaid = temp[key].subTotal
          } else{
            temp[key] = {};
            temp[key].productId = this.productList[i].productId;
            temp[key].quantity = this.productList[i].quantity;
            temp[key].subTotal = parseFloat(this.productList[i].price) * parseFloat(temp[key].quantity);
            temp[key].amountPaid = temp[key].subTotal
          }
          temp[key].subType = this.productList[i].subType;
          temp[key].name = this.productList[i].name;
          temp[key].sn = this.productList[i].sn;
          temp[key].price = this.productList[i].price;
          temp[key].cost = this.productList[i].cost;
          temp[key].orders = this.productList[i].orders;
          temp[key].discount = this.productList[i].discount;
          temp[key].spec = this.productList[i].spec;
          temp[key].unit = this.productList[i].unit
        }
      }
      for (var k in temp) {
        newfood.push(temp[k])
        console.log(newfood)
        console.log('xinz');
        console.log(temp[k])
      }
      this.productList = newfood
    },
  }
}
</script>
